<?php
class Quantri_Model_DonViTinh extends Zend_Db_Table_Abstract
{
	protected $_name="dmdonvitinh";
	protected $_primary="Id";

	var $Id, $Ten,$TrangThai;

	public function __construct() {
		$this->_name = Zend_Registry::get('tablePrefix') . $this->_name;

		parent::__construct();
	}


	public function GetAll() {

		$data = $this->fetchall();
		return $data;
	}

	public function save()
	{
		$data = array(
				'Ten' 	=> $this->Ten,
				'TrangThai' => $this->TrangThai
		);
		if($this->Id=="-1")
			$this->insert($data);		
		else
			$this->update($data, "Id = '$this->Id'");
	}

	public function xoa($id)
	{
		$this->delete("id='". $id . "'");
	}
	public function GetById()
	{
		return $this->fetchAll("Id='$this->Id'", "", 1)->toArray();
	}
}